//在index位置插入
void InsertByindex(size_t index ,ElementType &element)
{
    if(index>size)
        return;
    Node *TravePoint=head;
    for(size_t i=0;i<index;i++)
        TravePoint =TravePoint->next;
    Node *newNode=new Node(element);
    newNode->next=TravePoint->next;
    TravePoint->next=newNode;
    size++;
}
//通过元素删除
void RemoveByelement(ElementType &element)
{
    Node *Tp=head;
    while(tp->next!=nullptr)
    {
        if(tp->next->value==element)
        {
            Node *freenode=tp->next;
            tp->next=freenode->next;
            delete freenode;
            size--;
            
        }
        else
            Tp=Tp->next;
    }
}
//单链表冒泡排序
void BobSort()
{
    for(int i=0;i<size-1;i++)
    {
        Node *Tp=head;
        for(int j=0;i<size-1-i;j++)
        {
            if(tp->next->value>tp->next->next->value)
            {
                Node *prev=tp->next;
                Node *back=tp->next->next;
                prev->next=back->next;
                back->next=prev;
                tp->next=back;
            }
            tp=tp->next;
        }
    }

}
//单链表快速排序（快慢指针）
void sort()
{
    FastSort(head->next,nullptr);
}
void FastSort(Node* start,Node*end)
{
    if(start==end)
        return;
    Node *tmp=start;
    Node *slow=start;
    Node *fast=start->next;
    while(fast->next!=nullptr)
    {
        if(fast->value<tmp->value)
        {
            slow=slow->next;
            std::swap(slow->value,fast->value);
        }
        fast->nextw;
    }
    std::swap(tmp->value,slow->value);
    FastSort(start,slow);
    FastSort(slow->next;end);
}
//归并排序
LinkList Merge(const LinkList &list)
{
    LinkList result;
    Node *tp1=head->next;
    Node *tp2=list.head->next;
    while(tp1&&tp2)
    {
        if(tp1->value<tp2->value)
        {
            result.inserttail(tp1->value);
            tp1=tp1->next;
        }
            if(tp1->value>tp2->value)
        {
            result.inserttail(tp2->value);
            tp2=tp2->next;
        }
    }
    while(tp1)
    {
         result.inserttail(tp1->value);
            tp1=tp1->next;
    }
    while(tp2)
    {
        result.inserttail(tp2->value);
            tp2=tp2->next;
    }
} 
//链表倒叙
void Reserve()
{
    Node *prev=nullptr;
    Node *cur=head->next;
    Node *Next;head->next->next;
    while(Next!=nullptr)
    {
        //当前指针指向前面
        cur->next=prev;
        //指针往后移
        prev=cur;
        cur=Next;
        Next=cur->next;
    }
    cur->next=prev;
    head->next=cur;
}
//链表递归倒叙
void Reserve2()
{
    head->next=reserve(head->next);
}
Node *reserve(Node *node)
{
    if(node->next==nullptr)
        return node;
    Node *newhead=reseve(node->next);//递归往后走找到新链表的头
    node->next->next=node;
    node->next=nullptr;
    return newhead;
}

void resrve2()
{
    head->next=reserve(head->next)
}
void  reserve()
{
    if(node->next==nullptr)
        return node;
    node *newnode=reserve(node->next);
    node->next->next=node;
    node->next=nullptr;
    return newnode;
}